import 'package:flutter/material.dart';
import 'package:flutter_grammar/pages/dialog.dart';
import 'package:flutter_grammar/pages/form.dart';
import 'package:flutter_grammar/pages/hero.dart';
import 'package:flutter_grammar/pages/pageView.dart';
import 'package:flutter_grammar/pages/searchPage.dart';
import 'package:flutter_grammar/pages/swiperPage.dart';
import 'package:flutter_grammar/pages/tabs.dart';


//1、配置路由
Map routes = {
  "/": (contxt) => const Tabs(),
  "/search": (contxt) => const SearchPage(),
  "/form": (contxt, {arguments}) => FormPage(arguments: arguments),
  "/dialog": (contxt) => const DialogPage(),
  "/pageview" : (contxt) => const PageViewPage(),
  "/swiper" : (contxt) => const SwiperPage(),
  '/hero': (contxt,{arguments}) => HeroPage(arguments:arguments), 
};

var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));

      return route;
    }
  }
  return null;
};
